package han.cirno.corrupt.util

object ColorUtil {
    fun red(color:Int):Float{
        return ((color and 0x00FF0000)shr 16)/255f
    }

    fun green(color: Int):Float{
        return ((color and 0x0000FF00)shr 8) /255f
    }

    fun blue(color: Int):Float{
        return ((color and 0x000000FF)shr 0) /255f
    }

    fun alpha(color: Int):Float{
        return ((color and 0xFF000000.toInt())shr 24) /255f
    }

    fun ofRGBA(r:Float,g:Float,b:Float,a:Float):Int {
        return ((r*255f).toInt() shl 16) or
                ((g*255f).toInt() shl 8) or
                ((b*255f).toInt() shl 0) or
                ((a*255f).toInt() shl 24)
    }
}